<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>AngelScript: Arrays</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">AngelScript
   
   </div>
   
  </td>
  
  
  
   
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('doc_datatypes_arrays.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">Arrays </div>  </div>
</div>
<div class="contents">
<div class="textblock"><p><b>Observe:</b> Arrays are only available in the scripts if the application registers the support for them. The syntax for using arrays may differ for the application you're working with so consult the application's manual for more details.</p>
<p>It is possible to declare array variables by appending the [] brackets to the type. When declaring a variable with a type modifier, i.e. [], the type modifier affects the type of all variables in the list. Example:</p>
<pre>
  int[] a, b, c;
</pre><p><code>a</code>, <code>b</code>, and <code>c</code> are now arrays of integers.</p>
<p>When declaring arrays it is possible to define the initial size of the array by passing the length as a parameter to the constructor. The elements can also be individually initialized by specifying an initialization list. Example:</p>
<pre>
  int[] a;           // A zero-length array of integers
  int[] b(3);        // An array of integers with 3 elements
  int[] c(3, 1);     // An array of integers with 3 elements, all set to 1 by default
  int[] d = {,3,4,}; // An array of integers with 4 elements, where
                     // the second and third elements are initialized
</pre><p>Multidimensional arrays are supported as arrays of arrays, for example:</p>
<pre>
  int[][] a;                // An empty array of arrays of integers
  int[][] b = {{1,2},{3,4}} // A 2 by 2 array with initialized values
  int[][] c(10, int[](10)); // A 10 by 10 array of integers with uninitialized values
</pre><p>Each element in the array is accessed with the indexing operator. The indices are zero based, i.e the range of valid indices are from 0 to length - 1.</p>
<pre>
  a[0] = some_value;
</pre><p>The standard array implementation also has the following methods:</p>
<pre>
  // Adding and removing elements
  void insertAt(uint index, const T&amp; in);
  void removeAt(uint index);
  void insertLast(const T&amp; in);
  void removeLast();</pre><pre>  // Determine size of array
  uint length() const;
  void resize(uint);</pre><pre>  // Sort the array
  void sortAsc();
  void sortAsc(uint index, uint count);
  void sortDesc();
  void sortDesc(uint index, uint count);
  void reverse();</pre><pre>  // Find elements
  int  find(const T&amp; in);
  int  find(uint index, const T&amp; in);
</pre> </div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>

    <li class="footer">Generated on Sun Jan 29 2012 15:41:04 for AngelScript by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
